<template>
    <page-frame class="expand-wait" :showPageRefresh="showPageRefresh" v-model:refresh-loading="pageRefreshLoading"
        @onRefresh="goBackOrForward(0)">
        <template #header-title>
            {{ title }}
        </template>
        <div class="main">
            <page-line-text label="Machine" :text="taskDetailInfo.short"></page-line-text>
            <page-line-text label="Product" :text="taskDetailInfo.prod"></page-line-text>
            <page-line-text label="Owner" :text="taskDetailInfo.owner"></page-line-text>
            <page-line-text label="Urgent" :text="getUrgentValue(taskDetailInfo.urgent)"></page-line-text>
            <page-line-text label="是否超时" :text="taskDetailInfo.system_state != 1 ? '超时' : '未超时'"></page-line-text>
            <page-line-text label="发单时间" :text="taskDetailInfo.publish_at"></page-line-text>
            <page-line-text label="取消时间" :text="taskDetailInfo.cancel_at"></page-line-text>

            <div class="w box-b p10">
                <van-button type="primary" class="w" plain round size="small" @click="goBackOrForward(-1)">
                    返回
                </van-button>
            </div>
            <page-footer class="m-t10">已到达最底部</page-footer>
        </div>
    </page-frame>
</template>
<script lang="ts">
import pageBase from '@/views/mixins/page-base'
//   import { PendingApi } from '@/apis/pending/pending'
import { Dialog, Notify, Toast } from 'vant'
import { type RequestCode } from '@/server/base'
import pageRefresh from '@/views/mixins/page-refresh'

import { PageFrame, PageLineText, PageFooter } from '@/importComponents';

type DetailInfo = {
    id: string | number
    completed_at: string
    updated_at: string
    owner: string
    short: string
    machine: string
    block: string | null
    type: string
    prod: string
    urgent: string
    state: string
    created_at: string
    system_state: string | number
    cancel_state: string | null
    reject_reason: string | null
    cancel_at: string
    publish_at: string
    start: string
    end: string
}

export default {
    mixins: [pageBase, pageRefresh],
    components: { PageFrame, PageLineText, PageFooter },
    props: {
        visible: {
            type: Boolean,
            default: false
        }
    },
    computed: {
        detail(): DetailInfo {
            const itemStr: any = this.$route.params.value
            return this.getParamsByString(itemStr) //JSON.parse(unescape(itemStr))
        },
        title(): string {
            if (!this.taskDetailInfo) {
                return `JAM-工单${this.detail.id}`
            }
            return `JAM-工单${this.detail.id}【${this.getCancelOrTransferState(this.taskDetailInfo.cancel_state).text}】`

        },
        // contents(): { [x: string]: any } {
        //     return this.detail.contents
        // }
    },
    methods: {

    },
    created() {
        this.getTaskDetailById(this.detail.id);
    }
}
</script>
  
<style scoped></style>
  